/* 
    点赞表
*/
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
import mongoose, { Document } from 'mongoose'
import { User } from './UserSchema.Schema'
import { Proposition } from './proposition.schema'
import { Comment } from './comment.schema'

export type LikeDoucment = Like & Document

@Schema({ timestamps: true })
export class Like {
  //点赞人
  @Prop({ required: true, ref: User.name })
  user: mongoose.Types.ObjectId
  //点赞的帖子ID
  @Prop({ default: null, ref: Proposition.name })
  proposition: mongoose.Types.ObjectId
  //点赞的评论ID
  @Prop({ default: null, ref: Comment.name })
  comment: mongoose.Types.ObjectId
}

export const likeSchema = SchemaFactory.createForClass(Like)
